package org.exam.system.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.exam.system.domain.Permission;
import org.exam.system.mapper.PermissionMapper;
import org.exam.system.service.IPermissionService;
import org.exam.system.query.PermissionQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public class PermissionServiceImpl implements IPermissionService {
    @Autowired
    private PermissionMapper permissionMapper;
    @Override
    public PageInfo<Permission> queryPage(PermissionQuery permissionQuery) {
        PageHelper.startPage(permissionQuery.getCurrentPage(), permissionQuery.getPageSize());
        List<Permission> data = permissionMapper.queryPage(permissionQuery);
        return new PageInfo<>(data);
    }
    @Override
    @Transactional
    public void add(Permission permission) {
        permissionMapper.add(permission);
    }
    @Override
    @Transactional
    public void delete(Long id) {
        permissionMapper.delete(id);
    }

    @Override
    public Permission get(Long id) {
        return permissionMapper.get(id);
    }

    @Override
    public List<Permission> getAll() {
        return permissionMapper.getAll();
    }


    @Override
    @Transactional
    public void update(Permission permission) {
        permissionMapper.update(permission);
    }


}
